package com.ge.util;

import java.util.ArrayList;
import java.util.List;

class SynLinkedListListenerManage implements SynLinkedListListener {
	
	protected List mEventList = null;

	public synchronized void addListener(SynLinkedListListener mListener) {
		if (mEventList == null) {
			mEventList = new ArrayList();
		}
		
		mEventList.add(mListener);
	}
	
	public synchronized void removeListener(SynLinkedListListener mListener) {
		if (mEventList == null) {
			return;
		}
		
		mEventList.remove(mListener);
	}

	public synchronized void eventAfter(int type, SynLinkedList list, Object o) {
		if (mEventList == null) {
			return;
		}
		
		for (int nItem=0; nItem<mEventList.size(); nItem++) {
			SynLinkedListListener mListener = (SynLinkedListListener)mEventList.get(nItem);
			mListener.eventAfter(type, list, o);
		}
	}

	public synchronized void eventBefore(int type, SynLinkedList list, Object o) {
		if (mEventList == null) {
			return;
		}
		
		for (int nItem=0; nItem<mEventList.size(); nItem++) {
			SynLinkedListListener mListener = (SynLinkedListListener)mEventList.get(nItem);
			mListener.eventBefore(type, list, o);
		}
	}
}
